home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / ddj0492.zip / DFLT11.ZIP / EMMINIT.C < prev    next >
Text File  |  1992-02-04  |  1KB  |  60 lines

  1. /* ------------- emminit.c --------------- */
  2.  
  3. /*
  4.  * LIM Expanded Memory Manager Driver Functions
  5.  * This is the initialization EMM code. Its memory is
  6.  * returned to DOS when the TSR becomes resident
  7.  */
  8.  
  9. #include "tsr.h"
  10.  
  11. static char emmsig[9];
  12.  
  13. /* ------- test for EMM installed in system -------- */
  14. BOOL emm_present(void)
  15. {
  16.     void interrupt (*emmvect)(void);
  17.     unsigned emmseg;
  18.  
  19.     emmvect = getvect(EMM);
  20.     emmseg = FP_SEG(emmvect);
  21.     movedata(emmseg, 10, _DS, (unsigned) emmsig, 9);
  22.     return (strncmp(emmsig, "EMMXXXX0", 8) == 0);
  23. }
  24.  
  25. /* ------- test if EMM is activated -------- */
  26. BOOL emm_working(void)
  27. {
  28.     _AH = TESTEMM;
  29.     return (emmint() != -1);
  30. }
  31.  
  32. /* ------- get the EMM page frame segment address ------ */
  33. int emm_pageframe(void)
  34. {
  35.      _AH = FRAME;
  36.     if (emmint() == -1)
  37.         return -1;
  38.     return _BX;
  39. }
  40.  
  41. /* ------- return number of EMM pages available --------- */
  42. int emm_pages_available(void)
  43. {
  44.     _AH = PAGECT;
  45.     if (emmint() == -1)
  46.         return -1;
  47.     return _BX;
  48. }
  49.  
  50. /* ------- allocate pages of EMM to an application ------ */
  51. int emm_allocate(int pagect)
  52. {
  53.     _AH = ALLOCATE;
  54.     _BX = pagect;
  55.     if (emmint() == -1)
  56.         return -1;
  57.     return _DX;
  58. }
  59.  
  60.